<template>
    <button @click="toParent">点击向父组件传递数据</button>
</template>

<script setup>
import { defineEmits } from 'vue'

const emit = defineEmits(['getMsg'])

function toParent() {
    // console.log('向父组件传递数据~~~')
    // this.$emit('getMsg', 10086)
    // console.log(this)    // undefined

    emit('getMsg', 10086)
}
</script>
